package com.itcast.yygh.hosp.controller;

import com.itcast.common.result.R;
import com.itcast.yygh.hosp.service.ScheduleService;
import com.itcast.yygh.model.model.hosp.Schedule;
import com.itcast.yygh.model.vo.hosp.ScheduleOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 排班数据的查询
 */

@Api("排班分页数据查询")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {
    //引入service
    @Resource
    private ScheduleService scheduleService;

    //查询排班分页数据根据医院编号和部门编号
    @ApiOperation("查询排班分页数据")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getScheduleRule(@PathVariable("page") long page,
                             @PathVariable("limit") long limit,
                             @PathVariable("hoscode") String hoscode,
                             @PathVariable("depcode") String depcode){
        //调用service中的方法
        Map<String,Object> map = scheduleService.getScheduleRule(page,limit,hoscode,depcode);
        return R.ok().data(map);
    }

    //查询排班的详情信息
    @ApiOperation("查询排班详情信息")
    @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public R getScheduleDetail(
            @PathVariable("hoscode") String hoscode,
            @PathVariable("depcode") String depcode,
            @PathVariable("workDate") String workDate){
        List<Schedule> list = scheduleService.getScheduleDetail(hoscode,depcode,workDate);
        return R.ok().data("list",list);
    }
    @ApiOperation(value = "根据排班id获取预约下单数据")
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(
            @ApiParam(name = "scheduleId", value = "排班id", required = true)
            @PathVariable("scheduleId") String scheduleId) {
        return scheduleService.getScheduleOrderVo(scheduleId);
    }

}
